package org.gxuwz.core.action;

import java.util.List;

import org.gxuwz.core.entity.TArea;
import org.gxuwz.core.entity.TPolicy;
import org.gxuwz.core.service.IAreaService;
import org.gxuwz.core.service.IPolicyService;
import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class PolicyAction extends ActionSupport implements ModelDriven<TPolicy>{
	TPolicy poil = new TPolicy();
    List<TPolicy> list;
	String runyear;
	String maxline;
	 @Autowired
	    IPolicyService poilService;
	@Override
	public TPolicy getModel() {
		// TODO Auto-generated method stub
		return poil;
	}
	
	public String list() {
		list = poilService.getAll(runyear, maxline);
		return "list";
	}
	public String getByAreaName(){
		poil = poilService.getByRunYear(runyear);
		return "list";
	}
	
	public String edit(){
		poil = poilService.getByRunYear(runyear);
		return "edit";
	}
	public String update(){
		poilService.update(poil);
		return list();
	}
	public String delete(){
		poil = poilService.getByRunYear(runyear);
		poilService.delete(poil);
		return this.list();
	}

	public TPolicy getPoil() {
		return poil;
	}

	public void setPoil(TPolicy poil) {
		this.poil = poil;
	}

	public List<TPolicy> getList() {
		return list;
	}

	public void setList(List<TPolicy> list) {
		this.list = list;
	}

	public String getRunyear() {
		return runyear;
	}

	public void setRunyear(String runyear) {
		this.runyear = runyear;
	}

	public String getMaxline() {
		return maxline;
	}

	public void setMaxline(String maxline) {
		this.maxline = maxline;
	}

	public IPolicyService getPoilService() {
		return poilService;
	}

	public void setPoilService(IPolicyService poilService) {
		this.poilService = poilService;
	}
	
	
}
